package com.example.erhuo.activity;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Shader;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.example.erhuo.R;

public class LoginAndRegisterActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }
        getSupportActionBar().hide(); //隐藏上方标题栏
        setContentView(R.layout.activity_login_and_register);
        //设置背景
        Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.first_background2);
        BitmapDrawable drawable = new BitmapDrawable(bitmap);
        drawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
        drawable.setDither(true);
        getWindow().setBackgroundDrawable(drawable);

        Button buttonLogin = findViewById(R.id.toLogin);
        Button buttonRegister = findViewById(R.id.toRegister);
        Button buttonSkip = findViewById(R.id.skip);


        buttonRegister.setOnClickListener(this);

        buttonLogin.setOnClickListener(this);

        buttonSkip.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.toLogin:
                Intent intent1 = new Intent(LoginAndRegisterActivity.this, LoginActivity.class);
                startActivity(intent1);
                break;
            case R.id.toRegister:
                Intent intent2 = new Intent(LoginAndRegisterActivity.this, RegisterActivity.class);
                startActivity(intent2);
                break;
            case R.id.skip:
                Intent intent3 = new Intent(LoginAndRegisterActivity.this, MainActivity.class);
                startActivity(intent3);
                this.finish();
                break;
        }
    }
}